package com.situ.stmall.admin.mapper;

import com.situ.stmall.admin.entity.Root;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface RootMapper {
    @Delete({
        "delete from root",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into root (id, rootname, ",
        "password, realname, ",
        "phone, status, head)",
        "values (#{id,jdbcType=INTEGER}, #{rootname,jdbcType=VARCHAR}, ",
        "#{password,jdbcType=VARCHAR}, #{realname,jdbcType=VARCHAR}, ",
        "#{phone,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{head,jdbcType=VARCHAR})"
    })
    int insert(Root row);

    @Select({
        "select",
        "id, rootname, password, realname, phone, status, head",
        "from root",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="rootname", property="rootname", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="realname", property="realname", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="head", property="head", jdbcType=JdbcType.VARCHAR)
    })
    Root selectByPrimaryKey(Integer id);
    
    @Select({
        "select",
        "id, rootname, password, realname, phone, status, head",
        "from root",
        "where rootname = #{name}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="rootname", property="rootname", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="realname", property="realname", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="head", property="head", jdbcType=JdbcType.VARCHAR)
    })
    Root selectByName(String name);

    @Select({
        "select",
        "id, rootname, password, realname, phone, status, head",
        "from root"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="rootname", property="rootname", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="realname", property="realname", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="head", property="head", jdbcType=JdbcType.VARCHAR)
    })
    List<Root> selectAll();

    @Update({
        "update root",
        "set rootname = #{rootname,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "realname = #{realname,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "head = #{head,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Root row);
}